package com.wocharging.back.admin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class WoChargingApplication {
    public static void main(String[] args) throws UnknownHostException {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        ConfigurableApplicationContext application = SpringApplication.run(WoChargingApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String profile = env.getProperty("spring.profiles.active");
        String path = env.getProperty("server.servlet.context-path");
        path = path.equals("/") ? "" : path;

        System.out.println("\n----------------------------------------------------------\n\t" +
                "程序启动环境:" + profile + "\n\t" +
                "程序启动地址信息:\n\t" +
                "本地: \thttp://localhost:" + port + path + "/\n\t" +
                "外部: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "swagger: \thttp://" + ip + ":" + port + path + "/swagger-ui/index.html\n\t" +
                "doc: \thttp://" + ip + ":" + port + path + "/doc.html\n\t" +
                "druid: \thttp://" + ip + ":" + port + path + "/druid/login.html\n\t" +
                "----------------------------------------------------------");
    }
}
